package com.example.myys.data.dao

import androidx.room.Dao
import androidx.room.Delete
import androidx.room.Insert
import androidx.room.OnConflictStrategy
import androidx.room.Query
import androidx.room.Update
import com.example.myys.data.entity.SettingLink

@Dao
interface SettingLinkDao {
    @Insert(onConflict = OnConflictStrategy.IGNORE)
    fun insert(settingLink: SettingLink)
    @Update
    fun update(settingLink: SettingLink)
    @Delete
    fun delete(settingLink: SettingLink)

    @Query("select * from setting_link where name=:name and type=:type")
    fun getSettingByNameType(name: String, type: String): SettingLink?

    @Query("select * from setting_link where type=:type and isChecked=1")
    fun getSettingByTypeIsChecked(type: String): SettingLink?

    @Query("select * from setting_link where type=:type")
    fun getSettingByType(type: String): List<SettingLink>

    @Query("update setting_link set isChecked=0 where type=:type")
    fun updateAllIsCheckedByType(type: String)

}